<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 定义一个数组[1,5,6,99,5,66,7,4,1,6,9]去掉数组里面的重复值(两种方法)
      function fn(c){

      

      // 1.
       
// 循环嵌套
      for (var j = 0; j <= c.length; j++) {
        for (var l = 0; l <= c.length; l++) {
            // 判断，如果c[j] === c[l]，并且这两个相等的数不是自身
          if (c[j] === c[l] && j!==l) {
            // 截取一位
           var d =c.splice(l,1)
          }
        }
      }
      return c;
     
    }
    var o=fn([1, 2, 1,8, 1,1,1,2, 3, 4, 5, 6, 7, 1, 2, 3,8,1,6,4,7])
    console.log(o);



      // 2.
      function fn1(arr){
       
      var res=[];
      for(var k=0;k<arr.length;k++){
        if(res.indexOf(arr[k])===-1){
          res.push(arr[k])
        }
      }
      return res;
      }
      
      console.log(fn1([1, 2, 1,8, 1,1,1,2, 3, 4, 5, 6, 7, 1, 2, 3,8,1,6,4,7]))

    </script>
  </body>
</html>
